home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / EasyTools / full packs / RandomX11 / RNGCodeV11.s < prev   
Text File  |  1992-09-02  |  1KB  |  44 lines

  1.  **** Leppard's wonderfully Random Number Generator V1.1 ****
  2.  
  3. Rnd        move.l    #DateStore,d1        ;pointer to our date storage array
  4.         CALLDOS    DateStamp            ;get date in Amiga format
  5.                                     ;Random number generator.. from..
  6.         clr.l    d0
  7.         clr.l    d1
  8.         
  9.         move.b    $bfe400,d0            ;CIA-A Timer A: Lo
  10.         move.b    $bfd600,d1            ;CIA-B Timer B: Lo
  11.         eor.l    d1,d0
  12.         move.b    $bfd400,d1            ;CIA-B Timer A: Lo
  13.         and.l    #%11111,d1
  14.         rol.l    d1,d0                
  15.         move.b    $bfe7000,d1            ;CIA-A Timer B: Lo
  16.         ror.l    d1,d0        
  17.  
  18.         move.w    $dff004,d1            ;Raster screen pos
  19.         eor.w    d1,d0
  20.         move.w    $dff006,d1            ;Raster screen pos
  21.         eor.w    d1,d0
  22.         move.l    DateStore+8,d1        ;AmigaDATE!
  23.         eor.l    d1,d0                
  24.         move.l    DateStore+4,d1
  25.         eor.l    d1,d0
  26.         move.l    DateStore,d1
  27.         eor.l    d1,d0
  28.         move.l    d0,d2
  29.         swap    d2                    ;use 2nd word as another random source
  30.         eor.w    d2,d0
  31.  
  32.         addq.l    #1,d3
  33.         mulu    d3,d0                ;d3 = max number + 1 
  34.         divu    #65535,d0
  35.         and.l    #$0000FFFF,d0
  36.  
  37.         cmp.l    d0,d3                ;d3 = max + 1 remember.. this is *POSSIBLE* just bloody unlikely (I think)
  38.         bne        Thepa
  39.         subq.l    #1,d0                ;make it max
  40.         rts
  41.  
  42. DateStore
  43.         ds.l    3
  44.